package com.itdachang.design.structural.adapter.obj;

import com.itdachang.design.structural.adapter.Player;
import com.itdachang.design.structural.adapter.Translator;
import com.itdachang.design.structural.adapter.Zh_JPTranslator;

/**
 * 继承的方式：类结构模型，适配转换到了翻译器的功能上
 * @author gcq
 * @Create 2022-02-09
 */
public class JPMoviePlayerAdapter implements Player {

    /**
     * 组合方式
     */
    private Translator translate = new Zh_JPTranslator();
    /**
     * 被适配对象
     */
    private Player target;

    public JPMoviePlayerAdapter(Player target) {
        this.target = target;
    }

    @Override
    public String player() {
        String player = target.player();

        // 转换字幕
        String str = translate.translate(player);
        System.out.println("日文：" + str);
        return str;
    }
}
